// 04jyhs/accountAdmin/moneyDetail/moneyDetail.js
var co = require('../../../resource/js/common.js')
var app = getApp()
var _this,_data
var _pageNum = 1

Page({
   data: {
      details: [],
      hint: true,
      win_height: 1800,
   },
   onLoad(options) {
      _this = this
      _data=_this.data
      _this.setData({
         win_height: wx.getSystemInfoSync().windowHeight + 10
      })
      _this.getMoneyRecord()
   },

   onUnload() {
      _pageNum = 1
   },
   onReachBottom() {
      _this.getMoneyRecord()
   },

   //获取资金流水记录
   getMoneyRecord() {
      var Type = app.Data.userInfo.User_Type
      var param = {
         page: _pageNum
      }
      if(Type == "jyhsb"){
         param.User_ID = app.Data.userInfo.User_ID
         co.getJyhsApi("money/Recorduser/getList",param,function(res){
             _this.success(res)
         })
      } else if (Type == "jyhs_admin"){
        param.Biz_ID = app.Data.shopInfo.Biz_ID
         co.getJyhsApi("money/Recordbiz/getList",param,function(res){
           _this.success(res)
        })
      }
   },
   success(res) {
      if (res.code == 0) {
         var list = _data.details
         _this.setData({
            details: list.concat(res.data)
         })
         _pageNum++
         co.toastAllText(res.msg)
      } else {
         _this.setData({
            hint: false
         })
         co.toastAllText('没有记录了')
      }
   },
   //item点击事件
   itemClick(e) {
      var index = e.currentTarget.id
      var obj = _data.details[index]
      wx.navigateTo({
         url: '/04jyhs/accountAdmin/moneyDetail/moneyRecDetail/moneyRecDetail?detail=' + JSON.stringify(obj),
      })
   },
})